package cn.com.util;

import java.util.ArrayList;
import java.util.List;

/**
 * 算法类
 * @author 龙战广
 */
public class Arithmetic {
    /**
     * 预测分数线的算法方法
     * @param gradeAdmiIonlines 历年批次线集合
     * @param academyAdmiIonlines 历年分数线集合
     * @param years 年数
     * @param score 今年的批次线
     * @return 预测出来的分数线（float）
     */
    public static Integer forecastScore(List<Integer> gradeAdmiIonlines,List<Integer> academyAdmiIonlines, int years,int score){
        int gradeSize = gradeAdmiIonlines.size();
        int academySize = academyAdmiIonlines.size();
        if(gradeSize<years || academySize<years){
            return 0;
        }
        float sum = 0;
        float gradeAdmiIonline;
        float academyAdmiIonline;
        for(int i=0;i<years;i++){
            gradeAdmiIonline = gradeAdmiIonlines.get(i);
            System.out.println("批次线"+gradeAdmiIonline);
            academyAdmiIonline = academyAdmiIonlines.get(i);
            System.out.println("学校分数线"+academyAdmiIonline);
            sum += academyAdmiIonline/gradeAdmiIonline;
            System.out.println("系数"+sum);
        }
        score = (int) (score*(sum/years));
        return score;
    }

    /**
     * 对录取率的预测概率算法方法
     * @param forecastLine 预测分数线
     * @param score 实际分数
     * @return 预测出来的录取概率（String）
     */
    public static Integer probability(Integer forecastLine,Integer score){
        Float coefficient;
        Integer probability;
        if(score-forecastLine>20){
            System.out.println(1);
            coefficient = 10/(750f-forecastLine-20);
            probability =(int) (coefficient *(score-forecastLine-20)+90);
        }else if(0<=score-forecastLine && score-forecastLine<=20){
            System.out.println(2);
            probability =(score-forecastLine)*15/10+60;
        }else if(0<forecastLine-score && forecastLine-score<=20){
            System.out.println(3);
            probability = 60-((forecastLine-score)*(40/20));
        }else {
            System.out.println(4);
            coefficient = 20f/(forecastLine-20);
            probability =(int) (20-(coefficient*(forecastLine-20-score)));
        }
        return probability;
    }
}